#ifndef MULTITREE_H_
#define MULTITREE_H_
#include <iostream>
//Multitree - the way to represent an expression.
#include "Symbol.h"
namespace SymCe{
	struct ListOfChilds;
	struct Multitree{
	//	Multitree(Symbol & s);
		Symbol symbol;
		ListOfChilds * childs;
		//bool operator==(const Multitree * second) const;

	};

	struct ListOfChilds{
		Multitree * subtree;
		ListOfChilds * next;
		bool inverted;
	};

	/*bool operator==(const Multitree * first, const Multitree * second) const;
	bool operator<(const Multitree * first, const Multitree * second) const;*/

	Multitree* copy_tree(Multitree * tree);
	void delete_tree(Multitree * tree);
	int treecmp(Multitree * first, Multitree * second); //Compares trees - similar to strcmp.
	std::ostream & output_tree(Multitree * tree, std::ostream & stream);
	void rehang_tree(Multitree * tree); //There should not be PLUS operator as child of another PLUS in tree.
										//And same holds for MULTIPLY operator. This function merges such nodes, if needed.
	void sort_tree(Multitree * tree); //Sorts the sons of some operations.
	Multitree * reduce_tree(Multitree * tree);
	Multitree * diff_tree(Multitree * tree, char * variable); //Will be called from method in expression, so variable does not have to be tested.
	bool is_number(Multitree * tree, Number number);
	void delete_childs(ListOfChilds * childs);
	Multitree * replace_variable_tree(Multitree * original, char * variable, Multitree * with);
	Multitree * expand_tree(Multitree * tree);
	Multitree * canonicalize_tree(Multitree * tree);
	Number numeric(Multitree * tree);
	//C constructors :-)
	Multitree * give_me_empty_tree();
	Multitree * give_me_tree_with_two_childs();
	ListOfChilds * give_me_empty_child();
	Multitree * taylorize(Multitree * tree, Number center, unsigned short int terms, char * variable);

}







#endif /*MULTITREE_H_*/
